package data

import (
	"fmt"

	_ "github.com/go-sql-driver/mysql"
	"github.com/lunny/xorm"
)

type Book struct {
	Bid     int `xorm:"pk"`
	Name    string
	Initial string
	Author  string
	Press   string
	Brief   string
	Cover   string
	Chick   int
	Status  int
}

func (this *Book) Insert(e *xorm.Engine) error {
	_, err := e.InsertOne(this)
	return err
}

func (this *Book) Update(e *xorm.Engine) error {
	fmt.Println("updated")
	bid := this.Bid
	this.Bid = 0
	_, err := e.Id(bid).Update(this)
	return err
}
